<%--
  Created by IntelliJ IDEA.
  User: Tolean
  Date: 2018/6/4
  Time: 11:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Lyon-Admin</title>
    <%@include file="common/head.jspf"%>
    <link rel="Shortcut Icon" href="${lyon}/static/images/favicon.ico"  />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="${lyon}/interface/admin/common/layui/css/font.css">
    <link rel="stylesheet" href="${lyon}/interface/admin/common/layui/css/xadmin.css">
    <script type="text/javascript" src="${lyon}/static/assets/js/jquery.min.js"></script>
    <script src="${lyon}/interface/admin/common/layui/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${lyon}/interface/admin/common/layui/js/xadmin.js"></script>
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <%--<a href="">首页</a>--%>
        <%--<a href="">演示</a>--%>
        <a>
          <cite>博客</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" action="${blog}/admin/quotationsList.html">
            <input type="text" name="keyword"  placeholder="请输入关键字" autocomplete="off" class="layui-input" value="${keyword}">
            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>
    <xblock>
        <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
        <button class="layui-btn" onclick="x_admin_show('添加博客分类','${lyon}/admin/quotationsAdd.html')"><i class="layui-icon"></i>添加</button>
        <span class="x-right" style="line-height:40px">共有数据：${pageInfo.getTotal()} 条</span>
    </xblock>
    <table class="layui-table">
        <colgroup>
            <col >
            <col >
            <col >
            <col width="50%">
            <col >
        </colgroup>
        <thead>
        <tr>
            <th>
                <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th>ID</th>
            <th>来源</th>
            <th>内容</th>
            <%--<th>博客类别</th>--%>
            <th >操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${quotations}" var="i">
        <tr>
            <td>
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='${i.id}'><i class="layui-icon">&#xe605;</i></div>
            </td>
            <td>${i.id}</td>
            <td>${i.title}</td>
            <td>${i.content}</td>
            <td class="td-manage">
                <a title="查看-修改"  onclick="x_admin_show('修改语录','${lyon}/admin/quotationEdit.html?id='+${i.id})" href="javascript:;">
                    <i class="layui-icon">&#xe63c;</i>
                </a>
                <a title="删除" onclick="dele(this,${i.id})" href="javascript:;">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
            </c:forEach>
        </tr>
        </tbody>
    </table>
    <div id="laypage">
    </div>

</div>
<script>
    layui.use('laypage', function(){
        var laypage = layui.laypage;
        //执行一个laypage实例
        laypage.render({
            elem: 'laypage' //注意，这里的 test1 是 ID，不用加 # 号
            ,count: ${pageInfo.getTotal()} //数据总数，从服务端得到
            ,limit: 10
            ,curr: ${pageInfo.getPageNum()}
            ,jump: function(obj,first) {
                if(!first){
                    location.href='?pageNum='+obj.curr+'&pageSize='+obj.limit+'&keyword='+'${keyword}';
                }
            }
        });
    });
    /*删除*/
    function dele(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.post("${lyon}/admin/quotationDele.do",{id:id},function (res) {
                if(res.success){
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                }else{
                    layer.msg('删除失败!',{icon:2,time:1000});
                }
            },"json");
        });
    }

    function delAll (argument) {
        var data = tableCheck.getData();
        layer.confirm('确认要删除吗？'+data,function(index){
            //捉到所有被选中的，发异步进行删除
            $.post("${lyon}/admin/quotationsDele.do",{ids:data.toString()},function (res) {
                if(res.success){
                    layer.msg('删除成功!', {icon: 1,time:1000});
                    $(".layui-form-checked").not('.header').parents('tr').remove();
                }else{
                    layer.msg('删除失败!', {icon: 2,time:1000});
                }
            },'json');
        });
    }
</script>
</body>
</html>